package uds.android.fitdroid.ui.tabs;

import uds.android.fitdroid.R;
import uds.android.fitdroid.map.MapsActivity;
import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TableLayout;

public class RunSetup extends ActivityGroup {
	protected static final String TAG = "runsetup";

	private Button startbutton;
	private TableLayout contentlayout = null;
	private LocalActivityManager mActivityManager = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.runsetup);

		startbutton = (Button) findViewById(R.id.startbutton);
		startbutton.setOnClickListener(startbuttonListener);

		contentlayout = (TableLayout) findViewById(R.id.widget30);
		mActivityManager = getLocalActivityManager();
	}

	private OnClickListener startbuttonListener = new OnClickListener() {
		public void onClick(View v) {
			Intent i = new Intent(RunSetup.this, MapsActivity.class);
			startActivity(i);
		}
	};

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {

			TabTracker.getInstance().pop();
			if (TabTracker.getInstance().isEmpty()) {
				return false;
			} else {
				TabTracker
						.getInstance()
						.getTabHost()
						.setCurrentTab((Integer) TabTracker.getInstance().pop());
				return true;
			}
		}
		return false;
	}
}
